#!/usr/bin/env node

var client = require('share').client;
var options = require('../dynamo/db/options');
var cr = require('../dynamo/db/create');
var time = 42000;


var AWS = require('aws-sdk');

//carico i dati per amazon
AWS.config.update({accessKeyId: options.db.amazon_access_key, secretAccessKey: options.db.amazon_secret_key, region: options.db.amazon_region});

//dichiaro le variabili per amazon
var db = new AWS.DynamoDB();
var s3 = new AWS.S3();

client.open('test', 'text', 'http://localhost:9000/channel', function(error, doc) {
	// Insert some text at the start of the document (position 0):
    if (error != null){
    	console.log("ERRORE!!!!!!!!!!!!!!!!!!!! "+error);
    }

            // for (i = 1; i <= 10; i++){
            //     setTimeout(function(){
            //         doc.insert(0, text+'_'+i+'\n');
            //         console.log(doc.snapshot); 
            //     },(7000));
            // }
            // Get the contents of the document for some reason:
            console.log(doc.snapshot);
            // doc.on('change', function(op) {
            //     console.log('Version: ' + doc.version);
            // });
            // Close the doc if you want your node app to exit cleanly
            doc.close();
        });
client.open('t2', 'text', 'http://localhost:9000/channel', function(error, doc) {
	// Insert some text at the start of the document (position 0):
    if (error != null){
    	console.log("ERRORE!!!!!!!!!!!!!!!!!!!! "+error);
    }

            // for (i = 1; i <= 10; i++){
            //     setTimeout(function(){
            //         doc.insert(0, text+'_'+i+'\n');
            //         console.log(doc.snapshot); 
            //     },(7000));
            // }
            // Get the contents of the document for some reason:
            console.log(doc.snapshot);
            // doc.on('change', function(op) {
            //     console.log('Version: ' + doc.version);
            // });
            // Close the doc if you want your node app to exit cleanly
            doc.close();
        });
